<template>
	<view class="view">
		<view class="bill-list">
			<view class="bill-item" v-for="item in billList" :key="item.id">
				<!-- 订单图片 -->
				<view class="bill-pic">
					<image class="img" mode="widthFix" :src="item.goodsPicture"></image>
				</view>
				<view class="name">{{item.studentName}}的记忆</view>
				<view class="time">{{item.createTime}}</view>
				
				<view class="goodsDesc">{{item.goodsDesc}}</view>
				
				<view class="price-list">
					<view class="price">￥{{item.billPrice}}</view>
					<!-- 判断电子底片的情况 -->
					<view v-if="item.billStatus == 1  && item.billType == 1" > <button class="btn1" style="background-color: #008001;" @click="toCheckedPic(item.id)">已选</button></view>
					<view v-if="item.billStatus == 0  && item.billType == 1"> <button class="btn1" style="background-color: #FFBE18;" @click="toChoosePic(item)">未选</button></view>
					<!-- 判断实体相册的情况 -->
					<view v-if="item.billStatus == 1  && item.billType == 0" > <button class="btn1" style="background-color: #008001;" @click="toCheckedPic(item.id)">已完成</button></view>
					<view v-if="item.billStatus == 0  && item.billType == 0"> <button class="btn1" style="background-color: #FFBE18;" @click="toChoosePic(item)">未选</button></view>
					<view v-if="item.billStatus == 2  && item.billType == 0" > <button class="btn1" style="background-color: #db0000;" @click="toCheckedPic(item.id)">待制作</button></view>

					<view><button class="btn2" style="background-color: #FFBE18;" @click="toBuyAgain(item.goodsId)">再次订购</button></view>
				</view>
			</view>
			
			
		</view>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
				//订单列表
				billList:[],
				//绑定的学生列表
				studentList:[],
	
				//家长id
				parentId:null,	
			}
		},
//获取商品信息, 学生列表
		onLoad: function () { 
			this.parentId = uni.getStorageSync("parentId")
			this.getBillList();
		},
		
		onUnload() {
			uni.switchTab({
				url:"/pages/me/me"
			})
		},
		
		methods: {
			//获取订单列表
			getBillList(){
				uni.$api.billFindByParentId(this.parentId).then(result =>{
					this.billList = result
				})	
			},
			//点击已选
			toCheckedPic(id){
				uni.navigateTo({
					url:"/subpkg/parent/checkedPic/checkedPic?id="+id
				})
			},
			//点击再次订购
			toBuyAgain(goodsId){
				uni.navigateTo({
					url:"/subpkg/baby/tobuy/tobuy?goodsId="+goodsId
				})	
			},
			//点击未选
			toChoosePic(item){
				uni.$common.navigateTo("/subpkg/baby/choose-pic/choose-pic",{
					billInfo:encodeURIComponent(JSON.stringify(item))
				})
				
			}

			}
			
	}
</script>

<style>
	.bill-item{
		padding: 20rpx 30rpx;
		background-color: white;
		margin-bottom: 20rpx;
		height:620rpx;
	}

	.btn1{
		width: 160rpx;
		height: 60rpx;
		position:relative;
		top: -50rpx;
		font-size: 0.9rem;
		color: white;
		border-radius: 30rpx;
	}
	.btn2{
		display: inline-block;
		width: 160rpx;
		height: 60rpx;
		position:relative;
		top: -109rpx;
		left: 70%;
		font-size: 0.9rem;
		color: white;
		border-radius: 30rpx;
	}
	.name{
		font-weight: 700;
	}
	.img{
		width: 100%;
		border-radius: 30rpx;
	}
	.time{
		position:relative;
		top: -40rpx;
		left: 55%;
		font-size: 1rem;
		color: #c3c0c0;
	}
	.goodsDesc{
		font-size: 1.1rem;
	}
	.price-list{
		margin-top: 30rpx;
	}
	.price{
		color: red;
	}
</style>
